package com.esdut.ciremember;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;
import java.util.List;

/**
 * @Company  CiJI
 * @Classname WordDao
 * @Description TODO 完成单词的增加、删除、修改、模糊查询
 * @Author wenXin
 * Date 2021/6/30 21:10
 * Version 1.0
 */

//数据库访问对象
@Dao
public interface WordDao {
    @Insert
    void insertWords(Word... words);

    @Update
    void updataWords(Word... words);

    @Delete
    void deleteWords(Word... words);

    @Query("DELETE FROM WORD")
    void deleteALLWords();

    @Query("SELECT * FROM WORD ORDER BY ID DESC")
    LiveData<List<Word>> getAllWordsLive();

    @Query("SELECT * FROM WORD WHERE english_word LIKE :patten ORDER BY ID DESC")
    LiveData<List<Word>> findWordsWithPatten(String patten);

}
